//
//  CellOfCellOfHotDestination.m
//  FreeTravel
//
//  Created by 徐康 on 16/9/7.
//  Copyright © 2016年 KX. All rights reserved.
#import "UIImageView+WebCache.h"
#import "Masonry.h"
#import "CellOfCellOfHotDestination.h"
@interface CellOfCellOfHotDestination ()
@property (nonatomic,strong) UIImageView *imageViewOfPhoto;
@property (nonatomic, strong) UILabel *labelOfCount;
@property (nonatomic, strong) UILabel *labelOfLabel;
@property (nonatomic, strong) UILabel *labelOfCnname;
@property (nonatomic, strong) UILabel *labelOfEnname;
@end
@implementation CellOfCellOfHotDestination
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageViewOfPhoto = [[UIImageView alloc]init];
        self.labelOfCount = [[UILabel alloc]init];
        self.labelOfLabel = [[UILabel alloc]init];
        self.labelOfCnname = [[UILabel alloc]init];
        self.labelOfEnname = [[UILabel alloc]init];
        [self.contentView addSubview:self.imageViewOfPhoto];
        [self.contentView addSubview:self.labelOfCount];
        [self.contentView addSubview:self.labelOfLabel];
        [self.contentView addSubview:self.labelOfCnname];
        [self.contentView addSubview:self.labelOfEnname];
    }
    return self;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    [self.imageViewOfPhoto mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.right.equalTo(self.contentView);
    }];
    [self.labelOfCount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self.contentView.mas_width).multipliedBy(0.2);
        make.height.equalTo(self.contentView.mas_height).multipliedBy(0.125);
        make.top.equalTo(self.contentView.mas_top).mas_offset(10);
        make.right.equalTo(self.contentView.mas_right).mas_offset(-10);
    }];
    self.labelOfCount.font = [UIFont fontWithName:@"Helvetica-Bold" size:15.f];
    self.labelOfCount.textColor = [UIColor whiteColor];
    self.labelOfCount.backgroundColor = [UIColor blackColor];
    self.labelOfCount.alpha = 0.7;
    [self.labelOfLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self.contentView.mas_width).multipliedBy(0.2);
        make.height.equalTo(self.contentView.mas_height).multipliedBy(0.125);
        make.right.equalTo(self.contentView.mas_right).mas_offset(-10);
        make.top.equalTo(self.labelOfCount.mas_bottom);
    }];
    self.labelOfLabel.backgroundColor = [UIColor blackColor];
    self.labelOfLabel.alpha = 0.7;

    self.labelOfLabel.textColor = [UIColor whiteColor];
    self.labelOfLabel.font = [UIFont systemFontOfSize:12];
    [self.labelOfEnname mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self.contentView.mas_width);
        make.height.equalTo(self.contentView.mas_height).multipliedBy(0.125);
        make.left.equalTo(self.contentView.mas_left).mas_offset(10);
        make.bottom.equalTo(self.contentView.mas_bottom).mas_offset(-10);
    }];
    self.labelOfEnname.textColor = [UIColor whiteColor];
    self.labelOfEnname.font = [UIFont systemFontOfSize:12];

    [self.labelOfCnname mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self.contentView.mas_width);
        make.height.equalTo(self.contentView.mas_height).multipliedBy(0.125);
        make.left.equalTo(self.contentView.mas_left).mas_offset(10);
        make.bottom.equalTo(self.labelOfEnname.mas_top);
    }];
    self.labelOfCnname.font = [UIFont fontWithName:@"Helvetica-Bold" size:15.f];
    self.labelOfCnname.textColor = [UIColor whiteColor];
    
    self.labelOfCount.textAlignment = NSTextAlignmentCenter;
    self.labelOfLabel.textAlignment = NSTextAlignmentCenter;
    
}
- (void)setModel:(ModelOfContinentsHot_country *)model{
    _model = model;
    
    self.labelOfCount.text = [NSString stringWithFormat:@"%ld",model.count];
    self.labelOfLabel.text = model.label;
    self.labelOfCnname.text = model.cnname;
    self.labelOfEnname.text = model.enname;
    [self.imageViewOfPhoto sd_setImageWithURL:[NSURL URLWithString:model.photo]];
}
@end
